package com.fancy.learncenter.view;

import android.app.Activity;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.fancy.learncenter.activity.ResumeActivity;
import com.fancy.learncenter.activity.YgtPayActivity;
import com.fancy.learncenter.common.MyApplication;
import com.superservice.lya.R;

/**
 * Created by Hyy on 2016/11/4.
 */
public class PopupWindowResumeEdit extends PopupWindow {

    View locationView;
    Activity mContext;

    public PopupWindowResumeEdit(Activity mContext, View locationView) {
        this.mContext = mContext;
        this.locationView = locationView;
        popopView = LayoutInflater.from(MyApplication.context).inflate(R.layout.pupopwinodw_resume_edit, null);


        cancle = popopView.findViewById(R.id.cancel);
        creat = popopView.findViewById(R.id.creat);


        initPopupWionw();
    }

    View popopView;
    TextView cancle;
    TextView creat;

    private void initPopupWionw() {
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);

        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
//        this.setOutsideTouchable(true);

        popopView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PopupWindowResumeEdit.this.dismiss();
            }
        });
        this.update();

        this.setContentView(popopView);


//

        cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dismiss();
            }
        });

        creat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, ResumeActivity.class);
                mContext.startActivity(intent);
                dismiss();
            }
        });
    }

    public void isShow() {
        this.showAtLocation(locationView, Gravity.BOTTOM, 0, 0);
    }

    /**
     * 生成TranslateAnimation
     *
     * @param durationMillis 动画显示时间
     * @param start          初始位置
     */
    protected Animation getTranslateAnimation(int start, int end, int durationMillis) {
        Animation translateAnimation = new TranslateAnimation(0, 0, start, end);
        translateAnimation.setDuration(durationMillis);
        translateAnimation.setFillEnabled(true);
        translateAnimation.setFillAfter(true);
        return translateAnimation;
    }

    public FreeCallBack getFreeCallBack() {
        return freeCallBack;
    }

    public void setFreeCallBack(FreeCallBack freeCallBack) {
        this.freeCallBack = freeCallBack;
    }

    private FreeCallBack freeCallBack;

    public interface FreeCallBack {
        abstract void freeCallBack();
    }


}
